package com.oss.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 定义常量的工具类
 * @author mxs
 */
@Component
@PropertySource("classpath:application.yml")
@ConfigurationProperties(prefix = "aliyun.oss.file")
@Configuration
public class ConstantPropertiesUtils implements InitializingBean {
    @Value("${endpoint}")
    private String endPoint;
    @Value("${keyid}")
    private String keyId;
    @Value("${keysecret}")
    private String keySecret;
    @Value("${bucketname}")
    private String bucketName;

    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;
    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT = endPoint;
        ACCESS_KEY_ID = keyId;
        ACCESS_KEY_SECRET = keySecret;
        BUCKET_NAME = bucketName;
    }
}
